package com.ict.txmsv2.services;

import com.ict.txmsv2.mapper.ClicksMapper;
import com.ict.txmsv2.model.Clicks;
import com.ict.txmsv2.utils.SdfBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * @author yoleen
 * @date 2020/12/16 16:59
 */

@Service
public class ClicksService {
    @Autowired
    ClicksMapper clicksMapper;

    public boolean check(Integer learnId, Integer userId) {
        return clicksMapper.check(learnId, userId)<1;
    }

    public void add(Integer learnId, Integer userId) {
        String format = SdfBuilder.getSimpleDateFormat().format(new Date());
        Clicks clicks = new Clicks(learnId,format,userId);
        clicksMapper.insertSelective(clicks);
    }
}
